﻿using System.Collections.Generic;
using GameObjects;
using Microsoft.Xna.Framework;
using Network;
using GameObjects.MoveBehaviors;

namespace GameServer
{
    /// <summary>
    /// Здесь находится процесс игры (не меню)
    /// </summary>
    public class GameLogic
    {
        public static GameLogic Instance = new GameLogic();

        public List<Character> players;
        List<Character> bots;
        static int _curCharId = 1;

        private GameLogic()
        {
            Initialize();
        }

        public void Initialize()
        {
            players = new List<Character>();
            bots = new List<Character>();
            // монстер
            Character monster = CreateCharacter(false);
            monster.moveBehavior = new StupidMonsterMove(monster);
            monster.Position = new Vector2(300, 300);
            monster.Speed = 1;
            bots.Add(monster);
        }

        // создаём персонажа
        public Character CreateCharacter(bool isPlayer)
        {
            Character character = new Character(_curCharId++);
            character.Speed = 100;
            character.Position = new Vector2(100, 100);
            if (isPlayer)
            {
                players.Add(character);
                foreach (Character monster in bots)
                {
                    (monster.moveBehavior as StupidMonsterMove).AddTarget(character);
                }
            }
            else
            {
                bots.Add(character);
            }
            return character;
        }

        ///// <summary>
        ///// Allows the game component to update itself.
        ///// </summary>
        ///// <param name="gameTime">Provides a snapshot of timing values.</param>
        //public void Update()
        //{
        //    foreach (var player in players)
        //    {
        //        // отправка новых координат клиентам
        //        player.Move();
        //    }
        //    foreach (var bot in bots)
        //    {
        //        // отправка новых координат клиентам
        //        bot.Move();
        //    }
        //}
    }
}
